package com.mysteel.monitor.demo.config;

import com.mysteel.monitor.servlet.MysteelMonitorServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@Configuration
public class ServletConfig {


    @PostConstruct
    public  void init(){
        List<byte[]> strList = new ArrayList<>();
       Thread thread = new Thread(() -> {
        while (true){
            strList.add(new byte[1024]);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
       });
        thread.start();

    }
    //注册Servlet
    @Bean
    public ServletRegistrationBean myServlet(){
        return new ServletRegistrationBean(new MysteelMonitorServlet(), "/crm/mysteelmonitor/*");
    }
}
